]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
test-tool: Set up a temporary xdg-home directory
authorFlorian Müllner <fmuellner@gnome.org>
Thu, 27 Nov 2025 13:43:43 +0000 (14:43 +0100)
committerFlorian Müllner <fmuellner@gnome.org>
Thu, 27 Nov 2025 18:24:01 +0000 (19:24 +0100)
Currently the launched gnome-shell instance uses the regular xdg-home
directories, which means it picks up settings, extensions etc. from
the current user.

Avoid this by pointing the xdg-home dirs to a temporary directory, so
everything that respects the basedir spec runs with a clean slate.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3986>

src/gnome-shell-test-tool.in

index 74d4c1461a486b01b75828e7b54bf75f875cec81..35380da6618b1197094c9ae23db76b3de079778a 100755 (executable)
@@ -16,13 +16,17 @@ def show_version(option, opt_str, value, parser):
     print("GNOME Shell Test Tool @VERSION@")
     sys.exit()
 
-def start_shell(wrap=None, perf_output=None):
+def start_shell(xdg_home, wrap=None, perf_output=None):
     # Set up environment
     env = dict(os.environ)
 
     filters = ['Gnome-shell-perf-helper'] + options.extra_filter
     env['MUTTER_WM_CLASS_FILTER'] = ','.join(filters)
 
+    env['XDG_CACHE_HOME'] = f'{xdg_home}/cache'
+    env['XDG_CONFIG_HOME'] = f'{xdg_home}/config'
+    env['XDG_DATA_HOME'] = f'{xdg_home}/data'
+
     if perf_output is not None:
         env['SHELL_PERF_OUTPUT'] = perf_output
 
@@ -58,13 +62,14 @@ def start_shell(wrap=None, perf_output=None):
     return subprocess.Popen(args, env=env)
 
 def run_shell(wrap=None, perf_output=None):
-    # we do no additional supervision of gnome-shell,
-    # beyond that of wait
-    # in particular, we don't kill the shell upon
-    # receiving a KeyboardInterrupt, as we expect to be
-    # in the same process group
-    shell = start_shell(wrap=wrap, perf_output=perf_output)
-    shell.wait()
+    with tempfile.TemporaryDirectory() as xdg_home:
+        # we do no additional supervision of gnome-shell,
+        # beyond that of wait
+        # in particular, we don't kill the shell upon
+        # receiving a KeyboardInterrupt, as we expect to be
+        # in the same process group
+        shell = start_shell(xdg_home=xdg_home, wrap=wrap, perf_output=perf_output)
+        shell.wait()
     return shell.returncode == 0
 
 def gnome_hwtest_log(*args):